
from appium import webdriver

from APPauto.test_APPauto_practice.test_enterprise_wechat_app.po_add_del_member.package.get_app_datas import GetAppDatas
from APPauto.test_APPauto_practice.test_enterprise_wechat_app.po_add_del_member.package.main_package import MainPackage


class App:
    def __init__(self,path):
        datas = GetAppDatas(path)
        desired_caps = datas.get_desired_caps()
        ip = datas.get_ip()
        port = datas.get_port()
        # 初始化driver
        self.driver = webdriver.Remote(f"http://{ip}:{port}/wd/hub", desired_caps)
        self.driver.implicitly_wait(10)

    def restart_app(self):
        self.driver.close_app()
        self.driver.launch_app()

    def close_app(self):
        self.driver.close_app()

    def get_main_package(self):
        return MainPackage(self.driver)